﻿@Power.VisualizationPartialView(new
{
    Description = "验收清单多级节点",
    Parameters = new
    {
        NodeIdentifier = new { DisplayName = "节点标识符" },
        Count = new { DisplayName = "输出数量", Type = "Int32", ControlType = "Integer", DefaultValue = 99999 },
        Depth = new { DisplayName = "输出层数", Type = "Int32", ControlType = "Integer", DefaultValue = 2 },
        CurrentDepth = new { DisplayName = "当前层数", Type = "Int32", ControlType = "Integer", DefaultValue = 1 }
    }
})
@{
    var nodeService = new NodeService();
    string nodeIdentifier = Param.nodeIdentifier;
    int siteId=Param.siteId;
    string siteIndentifier=Param.siteIndentifier;//站点标识符
    //参数
    int Count = Param.Count ?? 99999; //输出数量
    int Depth = Param.Depth ?? 99; //输出层数
    int left = Param.left; //左边
    int right = Param.right; //右边
    int CurrentDepth = Param.CurrentDepth ?? 1; //当前层数
    var childNodes = nodeService.GetMany(n=> n.SiteId == siteId && n.Depth ==CurrentDepth && n.Left > left && n.Right < right).OrderBy(n => n.Left);
}

@foreach (var childnode in childNodes.Where(n=>n.NodeStatus ==NodeStatus.Open))
{
    var childCount=(childnode.Right - childnode.Left -1)/2; //获取子栏目总数
    int subDepth=childnode.Depth+1;//子栏目层级
    string nodeUrl;
    if (childnode.NodeType == NodeType.Link)
    {
        if(childnode.LinkUrl.StartsWith("http")){
            nodeUrl = childnode.LinkUrl;
        }
        else if(childnode.LinkUrl.StartsWith("{Site")){
            nodeUrl = Power.Url.NodeUrl(childnode);
        }
        else{
            nodeUrl = Power.Url.SiteUrl(siteIndentifier) + childnode.LinkUrl;;
        }
    }
    else
    {
        nodeUrl = Power.Url.SiteUrl(siteIndentifier) + Power.Url.NodeUrl(childnode);
    }

    string className = "li" + subDepth;

   
    if (childCount > 0)
    {
        className += " hasUl" + subDepth;
    }
    string on = "on" + subDepth;

    <li class="@className @Power.Focus(childnode.Identifier, on)">
        <a class="a@(subDepth)" href="@nodeUrl" target="_blank">@childnode.NodeName</a>
        <span>@nodeUrl</span>
        @if (childCount > 0 && subDepth < Depth)
        {
            <ul class="ul@(subDepth)">
                @Power.Partial("验收清单多级节点", new { NodeIdentifier = childnode.Identifier, Depth,siteId=siteId, siteIndentifier=siteIndentifier, left=childnode.Left, right=childnode.Right, CurrentDepth = subDepth })
            </ul>
        }
    </li>
}